<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class STeaScheduleInfo extends Model
{
    public $table = "s_tea_schedule_info";

    protected $fillable = [
        'teacher_id',
        'date_time',
		'time_0800',
		'time_0830',
		'time_0900',
		'time_0930',
		'time_1000',
		'time_1030',
		'time_1100',
		'time_1130',
		'time_1200',
		'time_1230',
		'time_1300',
		'time_1330',
		'time_1400',
		'time_1430',
		'time_1500',
		'time_1530',
		'time_1600',
		'time_1630',
		'time_1700',
		'time_1730',
		'time_1800',
		'time_1830',
		'time_1900',
		'time_1930',
		'time_2000',
		'time_2030',
		'time_2100',
		'time_2130',
		'time_2200',
		'time_2230',
		'time_2300',
		'time_2330',
        'created_at',
        'updated_at'
    ];

    public function teachers()
    {
        return $this->belongsTo('App\Models\STeacherInfo', 'teacher_id');
    }


    static public function getTeaScheduleByDay($teacher_id, $date_time)
    {
        return self::where([
            ['teacher_id', $teacher_id],
            ['date_time', $date_time]
        ])
        ->select( 'time_0800', 'time_0830', 'time_0900', 'time_0930', 'time_1000', 'time_1030', 'time_1100', 'time_1130', 'time_1200', 'time_1230', 'time_1300', 'time_1330', 'time_1400', 'time_1430', 'time_1500', 'time_1530', 'time_1600', 'time_1630', 'time_1700', 'time_1730', 'time_1800', 'time_1830', 'time_1900', 'time_1930', 'time_2000', 'time_2030', 'time_2100', 'time_2130', 'time_2200', 'time_2230', 'time_2300')
        ->first();
    }
}
